import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, OneToMany } from 'typeorm';
import { Category } from './category.entity'
import { ProductOption } from './product-option.entity'

@Entity('product')
export class Product {
  @PrimaryGeneratedColumn('uuid')
  skuId: string;

  @Column({ unique: true })
  productName: string;

  @Column('decimal')
  originalPrice: number;

  @Column('decimal')
  price: number;

  @Column('int')
  sales: number;

  @Column('simple-array')
  swiperImageList?: string[];

  @Column()
  mainPicUrl?: string;

  @Column('text')
  remake: string;

  @OneToMany(() => ProductOption, (productOption) => productOption.product, { cascade: true })
  ProductOptionList: ProductOption[];

  @ManyToOne(() => Category, (category) => category.productList)
  category: Category;
}

